import java.util.Scanner;

//  根据先序遍历的String 创建二叉树， 并且按中序遍历输出 ；
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine() ;
        TreeNode root = createTree(str) ;
        inOrder(root) ;

    }
    static int i = 0 ;
    public static TreeNode createTree(String str){
        if(i >= str.length()) return null ;
        TreeNode root = null ;
        if(str.charAt(i) != '#'){
            root = new TreeNode(str.charAt(i)) ;
            i++ ;
            root.left = createTree(str) ;
            root.right = createTree(str) ;
        }else{
            i ++ ;
        }
        return root ;
    }
    public static void inOrder(TreeNode root){
        if(root == null) return ;
        inOrder(root.left) ;
        System.out.print(root.val + " ") ;
        inOrder(root.right) ;
    }

}

class TreeNode{
    public   char val ;
    public TreeNode left ;
    public TreeNode right ;

    public TreeNode(char val) {
        this.val = val;
    }

}



